package com.csdj.t309tgspringboot.controller;

import com.csdj.t309tgspringboot.common.WebResult;
import com.csdj.t309tgspringboot.entity.Menu;
import com.csdj.t309tgspringboot.service.IMenuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/menu")
public class MenuController {
    @Resource
    private IMenuService iMenuService;

    @ResponseBody
    @GetMapping("/selP")
    public WebResult selP(@RequestParam(value = "typeId",required = false) Integer typeId){
        List<Menu> selPM = iMenuService.selP(typeId,0);
        WebResult webResult = new WebResult();
        webResult.putData("selPM",selPM);
        if(webResult!=null){
            return webResult;
        }
        return null;
    }

    @ResponseBody
    @PostMapping("selSon")
    public WebResult selSon(@RequestParam(value = "pid",required = false) Integer pid){
        List<Menu> selSon = iMenuService.selSon(pid);
        WebResult webResult = new WebResult();
        webResult.putData("selSon",selSon);
        if(webResult!=null){
            return webResult;
        }
        return null;
    }
}
